package com.cmfi.dao.PlcDao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.cmfi.domain.PlcEntity.PlcNode;

// TODO 添加@Mapper
@Mapper
public interface PlcNodeDao {

	@Select("select * from tbl_plc_node")
	public List<PlcNode> getAllPlcNode();

	@Select("select * from tbl_plc_node where isSubscribe=#{isSubscribe}")
	public List<PlcNode> getAllPlcNodeNeedSubscribe(boolean isSubscribe);

	@Select("select * from tbl_plc_node where nodeFunction=#{function} limit 1")
	public PlcNode getPlcNodeByFunction(String function);

	@Insert("insert into tbl_plc_node(id,plcNum,namespaceIndex,identifier,value,isSubscribe)"
			+ " values(#{id},#{plcNum},#{namespaceIndex},#{identifier},#{value},#{isSubscribe})")
	public int savePlcNode(PlcNode plc);

	@Delete("delete from tbl_plc_node where id = #{id}")
	void deleteById(Long id);

}
